package cn.wolfcode.rbac.web.controller.system_manage;

import cn.wolfcode.rbac.service.system_manage.IEmployeeService;
import cn.wolfcode.rbac.util.LoginException;
import cn.wolfcode.rbac.util.LoginResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @version 1.0
 * @Author:Cao Zhijian
 * @DATE:2020/12/27 0027 20:03:54
 */
@Controller
public class LoginController {

    @Autowired
    private IEmployeeService iEmployeeService;

    @RequestMapping("/login")
    @ResponseBody
    public LoginResult login(String username, String password){
        try {
//            System.out.println(username);
//            System.out.println("");
//            System.out.println("");
            iEmployeeService.login(username,password);
            return new LoginResult(200,"操作成功");
        }catch (LoginException e){
            e.printStackTrace();
            return new LoginResult(500,"账号或密码不正确");
        }catch (Exception e){
            e.printStackTrace();
            return new LoginResult(500,"系统繁忙");
        }
    }

}
